package net.azure.app;

import net.azure.app.view.AzureView;
import net.azure.app.view.ViewFactory;
import net.azure.app.view.menu.AzureMenu;
import net.azure.app.model.Risk;
import net.azure.app.model.Estimate;

import javax.swing.*;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: Venkatraman Kandaswamy
 * Date: 08-Jun-2008
 * Time: 11:08:29
 */
public class Azure {
    private JPanel BasePanel;
    private JTabbedPane tabbedPane1;
    private JPanel storyView;
    private JPanel gridView;
    private JPanel compareView;
    private JList mslList;
    private JTextField asAText;
    private JTextArea wantToText;
    private JTextArea soThatText;
    private JTextArea detailsText;
    private JTextArea queriesText;
    private JTextArea notesText;
    private JComboBox volatilityCombo;
    private JComboBox completenessCombo;
    private JComboBox complexityCombo;
    private JComboBox priorityCombo;
    private JComboBox calculatedRiskCombo;
    private JComboBox plannedCombo;
    private JComboBox maximumCombo;
    private JComboBox minimumCombo;
    private JComboBox likelyCombo;
    private JTabbedPane tabbedPane2;
    private JTabbedPane tabbedPane3;

    private JTextArea commentsText;

    public void createUIComponents() {
        for (Component component : tabbedPane1.getComponents()) {
            AzureView view = ViewFactory.getView(component);
            view.renderView(component, this);
        }
    }

    public void configureUI() {
        populateComboBoxes();
        createUIComponents();
    }

    private void populateComboBoxes() {
        Risk.Volatility[] volatilities = Risk.Volatility.values();
        for (Risk.Volatility volatility : volatilities) {
            this.getVolatilityCombo().addItem(volatility);
        }

        Risk.Completeness[] completenesses = Risk.Completeness.values();
        for (Risk.Completeness completeness : completenesses) {
            this.getCompletenessCombo().addItem(completeness);
        }

        Risk.Complexity[] complexities = Risk.Complexity.values();
        for (Risk.Complexity complexity : complexities) {
            this.getComplexityCombo().addItem(complexity);
        }

        Risk.Priority[] priorities = Risk.Priority.values();
        for (Risk.Priority priority : priorities) {
            this.getPriorityCombo().addItem(priority);
        }

        Risk.CalculatedRisk[] calculatedRisks = Risk.CalculatedRisk.values();
        for (Risk.CalculatedRisk calculatedRisk : calculatedRisks) {
            this.getCalculatedRiskCombo().addItem(calculatedRisk);
        }

        int[] estimateValues = Estimate.estimateValues();
        for (int estimateValue : estimateValues) {
            this.getMinimumCombo().addItem(estimateValue);
            this.getLikelyCombo().addItem(estimateValue);
            this.getMaximumCombo().addItem(estimateValue);
            this.getPlannedCombo().addItem(estimateValue);
        }
    }

    public void buildInterface() {
        JFrame frame = new JFrame();
        AzureMenu azureMenu = new AzureMenu();
        frame.setJMenuBar(azureMenu.buildMenuBar());
        frame.setContentPane(BasePanel);
        frame.setSize(1024, 768);
        frame.setTitle("358");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    public JTextField getAsAText() {
        return asAText;
    }

    public JTextArea getWantToText() {
        return wantToText;
    }

    public JTextArea getSoThatText() {
        return soThatText;
    }

    public JTextArea getDetailsText() {
        return detailsText;
    }

    public JTextArea getQueriesText() {
        return queriesText;
    }

    public JTextArea getNotesText() {
        return notesText;
    }

    public JComboBox getVolatilityCombo() {
        return volatilityCombo;
    }

    public JComboBox getCompletenessCombo() {
        return completenessCombo;
    }

    public JComboBox getComplexityCombo() {
        return complexityCombo;
    }

    public JComboBox getPriorityCombo() {
        return priorityCombo;
    }

    public JComboBox getCalculatedRiskCombo() {
        return calculatedRiskCombo;
    }

    public JComboBox getPlannedCombo() {
        return plannedCombo;
    }

    public JComboBox getMaximumCombo() {
        return maximumCombo;
    }

    public JComboBox getMinimumCombo() {
        return minimumCombo;
    }

    public JComboBox getLikelyCombo() {
        return likelyCombo;
    }

    public JList getMslList() {
        return mslList;
    }

    public JTextArea getCommentsText() {
        return commentsText;
    }


}
